<template>
  <div class="PersonnelCategory">
    <div class="pubBig pharmacopeia">
      <div class="h0">
        <p class="lt">药典类</p>
      </div>
      <div class="m0">
        <div class="form-group">
          <fieldset>
            <legend>查询条件</legend>
            <div>
              <p>
                <label>简码：</label>
                <input
                  v-model="model_jmC"
                  type="text"
                  class="form-control"
                  placeholder="药品代码/药品名称/拼音码"
                  style="width: 185px"
                />
              </p>
              <p><label>药品类别标志:</label><select
                  class="form-control"
                  v-model="model_drug_flagC"
                  placeholder="请选择"
                >
                  <option
                    v-for="(item,index) in model_select_drug_flag"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>剂型:</label><select
                  class="form-control"
                  v-model="model_drug_formC"
                  placeholder="请选择"
                >
                  <option
                    v-for="(item,index) in model_select_drug_form"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>毒理分类:</label><select
                  class="form-control"
                  v-model="model_toxi_propertyC"
                  placeholder="请选择"
                >
                  <option
                    v-for="(item,index) in model_select_toxi_property"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>otc类型:</label><select
                  class="form-control"
                  v-model="model_otcC"
                  placeholder="请选择"
                >
                  <option
                    v-for="(item,index) in model_select_otc"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>大输液标记:</label><select
                  class="form-control"
                  v-model="model_iv_flagC"
                  placeholder="请选择"
                >
                  <option
                    v-for="(item,index) in model_select_iv_flag"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>价格类别:</label><select
                  class="form-control"
                  v-model="model_price_classC"
                  placeholder="请选择"
                >
                  <option
                    v-for="(item,index) in model_select_price_class"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>停用标志:</label><select
                  class="form-control"
                  v-model="model_stop_flagC"
                  placeholder="请选择"
                >
                  <option
                    v-for="(item,index) in model_select_stop_flag"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p>
                <button
                  class="btn btn-default"
                  @click="queryz()"
                >查询</button>
              </p>
            </div>
          </fieldset>
        </div>
      </div>
      <div class="btnLine">
        <button
          class="btn btn-default"
          @click="addMasterUser()"
        >新增</button>
        <button
          class="btn btn-default"
          @click="savez()"
          id="33"
        >保存</button>
        <button
          class="btn btn-default"
          @click="deletez()"
        >删除</button>
        <button class="btn btn-default">审核</button>
        <button class="btn btn-default">打印</button>
        <label class="mark1">
          <input type="checkbox" />显示
        </label>
      </div>
      <div class="dUpMain">
        <div class="oneBox clearfix">
          <p class="p1">新增内容</p>
        </div>
        <div class="threeSet pucLab clearfix">
          <fieldset>
            <legend>基本属性</legend>
            <div>
              <p><label>药品代码:</label><input
                  class="form-control"
                  v-model="model_drug_code"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="1"
                  readonly
                /></p>

              <p><label>药品名称:</label><input
                  class="form-control"
                  v-model="model_drug_name"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="2"
                /></p>

              <p><label>药品规格:</label><input
                  class="form-control"
                  v-model="model_drug_spec"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="3"
                /></p>

              <p><label>单位:</label><select
                  class="form-control"
                  v-model="model_unit"
                  placeholder="请选择"
                  @change="submit1()"
                  id="4"
                >
                  <option
                    v-for="(item,index) in model_select_unit"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>药品类别:</label><select
                  class="form-control"
                  v-model="model_drug_flag"
                  placeholder="请选择"
                  @change="submit1()"
                  id="5"
                >
                  <option
                    v-for="(item,index) in model_select_drug_flag"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>剂型:</label><select
                  class="form-control"
                  v-model="model_drug_form"
                  placeholder="请选择"
                  @change="submit1()"
                  id="6"
                >
                  <option
                    v-for="(item,index) in model_select_drug_form"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>毒理分类:</label><select
                  class="form-control"
                  v-model="model_toxi_property"
                  placeholder="请选择"
                  @change="submit1()"
                  id="7"
                >
                  <option
                    v-for="(item,index) in model_select_toxi_property"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>otc类型:</label><select
                  class="form-control"
                  v-model="model_otc"
                  placeholder="请选择"
                  @change="submit1()"
                  id="8"
                >
                  <option
                    v-for="(item,index) in model_select_otc"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>限制等级:</label><select
                  class="form-control"
                  v-model="model_limit_class"
                  placeholder="请选择"
                  @change="submit1()"
                  id="9"
                >
                  <option
                    v-for="(item,index) in model_select_limit_class"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>大输液标记:</label><select
                  class="form-control"
                  v-model="model_iv_flag"
                  placeholder="请选择"
                  @change="submit1()"
                  id="10"
                >
                  <option
                    v-for="(item,index) in model_select_iv_flag"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>批准文号:</label><input
                  class="form-control"
                  v-model="model_pass_no"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="11"
                /></p>

              <p><label>gmp标志:</label><select
                  class="form-control"
                  v-model="model_gmp"
                  placeholder="请选择"
                  @change="submit1()"
                  id="12"
                >
                  <option
                    v-for="(item,index) in model_select_gmp"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

            </div>
          </fieldset>
          <fieldset>
            <legend>药品包装</legend>
            <div>
              <p><label>药库单位:</label><select
                  class="form-control"
                  v-model="model_unit"
                  placeholder="请选择"
                  @change="submit1()"
                  id="13"
                >
                  <option
                    v-for="(item,index) in model_select_unit"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>拆分系数:</label><input
                  class="form-control"
                  v-model="model_package_count"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="14"
                /></p>
              <p><label>药房单位:</label><select
                  class="form-control"
                  v-model="model_min_unit"
                  placeholder="请选择"
                  @change="submit1()"
                  id="15"
                >
                  <option
                    v-for="(item,index) in model_select_min_unit"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>药房规格:</label><input
                  class="form-control"
                  v-model="model_min_spec"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="16"
                /></p>

              <p><label>药房单位总量:</label><input
                  class="form-control"
                  v-model="model_dose"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="17"
                /></p>
              <p><label>总量单位:</label><select
                  class="form-control"
                  v-model="model_dose_unit"
                  placeholder="请选择"
                  @change="submit1()"
                  id="18"
                >
                  <option
                    v-for="(item,index) in model_select_dose_unit"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

            </div>
          </fieldset>
          <fieldset>
            <legend>分类</legend>
            <div>
              <p><label>价格类别:</label><select
                  class="form-control"
                  v-model="model_price_class"
                  placeholder="请选择"
                  @change="submit1()"
                  id="19"
                >
                  <option
                    v-for="(item,index) in model_select_price_class"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>住院收据分类:</label><select
                  class="form-control"
                  v-model="model_class_on_inp_rcpt"
                  placeholder="请选择"
                  @change="submit1()"
                  id="20"
                >
                  <option
                    v-for="(item,index) in model_select_class_on_inp_rcpt"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>门诊收据分类:</label><select
                  class="form-control"
                  v-model="model_class_on_oup_rcpt"
                  placeholder="请选择"
                  @change="submit1()"
                  id="21"
                >
                  <option
                    v-for="(item,index) in model_select_class_on_oup_rcpt"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>
              <p><label>核算项目分类:</label><select
                  class="form-control"
                  v-model="model_class_on_reckoning"
                  placeholder="请选择"
                  @change="submit1()"
                  id="22"
                >
                  <option
                    v-for="(item,index) in model_select_class_on_reckoning"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>会计科目:</label><select
                  class="form-control"
                  v-model="model_subj_code"
                  placeholder="请选择"
                  @change="submit1()"
                  id="23"
                >
                  <option
                    v-for="(item,index) in model_select_subj_code"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

              <p><label>病案首页费用分类:</label><select
                  class="form-control"
                  v-model="model_class_on_mr"
                  placeholder="请选择"
                  @change="submit1()"
                  id="24"
                >
                  <option
                    v-for="(item,index) in model_select_class_on_mr"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

            </div>
          </fieldset>
          <fieldset>
            <legend>高、低储</legend>
            <div>

              <p><label>药库高储:</label><input
                  class="form-control"
                  v-model="model_storage_upper_limit"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="25"
                /></p>

              <p><label>药库低储:</label><input
                  class="form-control"
                  v-model="model_storage_lower_limit"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="26"
                /></p>

              <p><label>药房高储:</label><input
                  class="form-control"
                  v-model="model_store_upper_limit"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="27"
                /></p>

              <p><label>药房低储:</label><input
                  class="form-control"
                  v-model="model_store_lower_limit"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="28"
                /></p>

            </div>
          </fieldset>
          <fieldset>
            <legend>其他</legend>
            <div>
              <p><label>批发价:</label><input
                  class="form-control"
                  v-model="model_trade_price"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="29"
                /></p>

              <p><label>零售价:</label><input
                  class="form-control"
                  v-model="model_retail_price"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="30"
                /></p>

              <p><label>最高限价:</label><input
                  class="form-control"
                  v-model="model_hlimit_price"
                  placeholder="请输入"
                  type="text"
                  @keyup.enter="submit1()"
                  id="31"
                /></p>

              <p><label>停用标志:</label><select
                  class="form-control"
                  v-model="model_stop_flag"
                  placeholder="请选择"
                  @change="submit1()"
                  id="32"
                >
                  <option
                    v-for="(item,index) in model_select_stop_flag"
                    :label="item.name"
                    :value="item.code"
                    :key="index"
                  ></option>
                </select></p>

            </div>
          </fieldset>
        </div>
      </div>
      <div class="dDownMain">
        <p class="p1">查询明细</p>
        <div
          class="twoBox"
          style="top:464px"
        >
          <table class="table table-bordered">
            <thead>
              <tr>
                <th
                  colspan="12"
                  style="text-align:center"
                >基本属性</th>
                <th
                  colspan="6"
                  style="text-align:center"
                >药品包装</th>
                <!-- <th colspan="6" style="text-align:center">分类</th> -->
              </tr>
              <tr>
                <td>药品代码</td>
                <td>药品名称</td>
                <td>规格</td>
                <td>单位</td>
                <td>剂型</td>
                <td>毒理分类</td>
                <td>OTC类型</td>
                <td>限制等级</td>
                <td>大输液标志</td>
                <td>批准文号</td>
                <td>GMP标志</td>
                <td>拆分系数</td>
                <td>价格类别</td>
                <td>住院收据分类</td>
                <td>门诊收据分类</td>
                <td>核算项目分类</td>
                <td>会计科目</td>
                <td>病案分类</td>
              </tr>
            </thead>
            <tbody>
              <tr
                v-for="(item,index) in model_query"
                :key="index"
                @click="openDetails(item,index) "
                :class="{selGreen:changeSelectStyle == index}"
              >
                <td>{{item.drug_code}}</td>
                <td>{{item.drug_name}}</td>
                <td>{{item.drug_spec}}</td>
                <td>{{item.unit_Name}}</td>
                <td>{{item.drug_form_Name}}</td>
                <td>{{item.toxi_property_Name}}</td>
                <td>{{item.otc_Name}}</td>
                <td>{{item.limit_class_Name}}</td>
                <td>{{item.iv_flag_Name}}</td>
                <td>{{item.pass_no}}</td>
                <td>{{item.gmp_Name}}</td>
                <td>{{item.package_count}}</td>
                <td>{{item.price_class_Name}}</td>
                <td>{{item.class_on_inp_rcpt_Name}}</td>
                <td>{{item.class_on_oup_rcpt_Name}}</td>
                <td>{{item.class_on_reckoning_Name}}</td>
                <td>{{item.subj_code_Name}}</td>
                <td>{{item.class_on_mr_Name}}</td>

              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "PersonnelCategory",
  data () {
    return {
      msg: "SystemManagement 下的 PersonnelCategory",
      model_operation_levelc: "",
      model_operation_level: "",

      //声明v_model
      model_class_on_inp_rcpt: "",
      model_class_on_mr: "",
      model_class_on_oup_rcpt: "",
      model_class_on_reckoning: "",
      model_create_time: "",
      model_dose: "",
      model_dose_unit: "",
      model_drug_code: "",
      model_drug_flag: "",
      model_drug_form: "",
      model_drug_name: "",
      model_drug_spec: "",
      model_gmp: "",
      model_hlimit_price: "",
      model_hospital_id: "",
      model_iv_flag: "",
      model_limit_class: "",
      model_min_spec: "",
      model_min_unit: "",
      model_otc: "",
      model_package_count: "",
      model_pass_no: "",
      model_price_class: "",
      model_pym: "",
      model_retail_price: "",
      model_stop_flag: "",
      model_storage_lower_limit: "",
      model_storage_upper_limit: "",
      model_store_lower_limit: "",
      model_store_upper_limit: "",
      model_subj_code: "",
      model_toxi_property: "",
      model_trade_price: "",
      model_unit: "",

      model_XZBJ: "",
      model_query_BC: [],

      model_query: [], //查询结果

      changeSelectStyle: '',

      //下拉数据源
      model_select_class_on_inp_rcpt: [], //住院收据分类
      model_select_class_on_mr: [], //病案首页费用分类
      model_select_class_on_oup_rcpt: [], //门诊收据分类
      model_select_class_on_reckoning: [], //核算项目分类
      model_select_create_time: [], //创建时间
      model_select_dose: [], //最小单位剂量
      model_select_dose_unit: [], //剂量单位
      model_select_drug_code: [], //药品代码
      model_select_drug_flag: [], //药品类别标志
      model_select_drug_form: [], //剂型
      model_select_drug_name: [], //药品名称
      model_select_drug_spec: [], //药品规格
      model_select_gmp: [], //gmp标志
      model_select_hlimit_price: [], //最高限价
      model_select_hospital_id: [], //医院编号
      model_select_iv_flag: [], //大输液标记
      model_select_limit_class: [], //限制等级
      model_select_min_spec: [], //最小单位规格
      model_select_min_unit: [], //最小单位
      model_select_otc: [], //otc类型
      model_select_package_count: [], //包装数量
      model_select_pass_no: [], //批准文号
      model_select_price_class: [], //价格类别
      model_select_pym: [], //拼音码
      model_select_retail_price: [], //零售价
      model_select_stop_flag: [], //停用标志
      model_select_storage_lower_limit: [], //药库下限
      model_select_storage_upper_limit: [], //药库上限
      model_select_store_lower_limit: [], //药房下限
      model_select_store_upper_limit: [], //药房上限
      model_select_subj_code: [], //会计科目
      model_select_toxi_property: [], //毒理分类
      model_select_trade_price: [], //批发价
      model_select_unit: [], //单位

      //查询数据
      model_class_on_inp_rcptC: "", //住院收据分类
      model_drug_formC: "", //剂型
      model_toxi_propertyC: "", //毒理分类
      model_otcC: "", //otc类型
      model_iv_flagC: "", //大输液标记
      model_price_classC: "", //价格类别
      model_stop_flagC: "", //停用标志
      model_class_on_reckoningC: "",
      model_jmC: "",
      model_drug_flagC: "",

      drug_dict: {
        columns: [
          { field: "drug_code", title: "药品代码", width: "100" },
          { field: "drug_name", title: "药品名称" },
          { field: "drug_spec", title: "药品规格" },
          { field: "unit", title: "单位" },
          { field: "drug_form", title: "剂型" },
          { field: "toxi_property", title: "毒理分类" },
          { field: "otc", title: "otc类型" },
          { field: "limit_class", title: "限制等级" },
          { field: "iv_flag", title: "大输液标记" },
          { field: "pass_no", title: "批准文号" },
          { field: "gmp", title: "gmp标志" },
          //药库单位和单位一个东西
          { field: "package_count", title: "拆分系数" }, //包装数量
          { field: "min_unit", title: "药房单位" }, //最小单位
          { field: "min_spec", title: "药房规格" }, //最小单位规格
          { field: "dose", title: "药房单位总量" }, //最小单位剂量
          { field: "dose_unit", title: "总量单位" }, //剂量单位
          { field: "price_class", title: "价格类别" },
          { field: "class_on_inp_rcpt", title: "住院收据分类" },
          { field: "class_on_oup_rcpt", title: "门诊收据分类" },
          { field: "class_on_reckoning", title: "核算项目分类" },
          { field: "subj_code", title: "会计科目" },
          { field: "class_on_mr", title: "病案费用分类" }
        ],
        data: []
      },
      currentPage: 1,
      total: 0,
      pagesize: 5,
      Newlyadded: false
    };
  },
  methods: {
    openDetails (row, index) {
      this.Newlyadded = true;
      this.model_class_on_inp_rcpt = row.class_on_inp_rcpt;
      this.model_class_on_mr = row.class_on_mr;
      this.model_class_on_oup_rcpt = row.class_on_oup_rcpt;
      this.model_class_on_reckoning = row.class_on_reckoning;
      this.model_create_time = row.create_time;
      this.model_dose = row.dose;
      this.model_dose_unit = row.dose_unit;
      this.model_drug_code = row.drug_code;
      this.model_drug_flag = row.drug_flag;
      this.model_drug_form = row.drug_form;
      this.model_drug_name = row.drug_name;
      this.model_drug_spec = row.drug_spec;
      this.model_gmp = row.gmp;
      this.model_hlimit_price = row.hlimit_price;
      this.model_hospital_id = row.hospital_id;
      this.model_iv_flag = row.iv_flag;
      this.model_limit_class = row.limit_class;
      this.model_min_spec = row.min_spec;
      this.model_min_unit = row.min_unit;
      this.model_otc = row.otc;
      this.model_package_count = row.package_count;
      this.model_pass_no = row.pass_no;
      this.model_price_class = row.price_class;
      this.model_pym = row.pym;
      this.model_retail_price = row.retail_price;
      this.model_stop_flag = row.stop_flag;
      this.model_storage_lower_limit = row.storage_lower_limit;
      this.model_storage_upper_limit = row.storage_upper_limit;
      this.model_store_lower_limit = row.store_lower_limit;
      this.model_store_upper_limit = row.store_upper_limit;
      this.model_subj_code = row.subj_code;
      this.model_toxi_property = row.toxi_property;
      this.model_trade_price = row.trade_price;
      this.model_unit = row.unit;
      this.changeSelectStyle = index;

      console.log(row);
    },
    handleChange (val) {
      console.log(val);
    }, //主表保存
    quxiao () {
      this.Newlyadded = false;
    },
    //主表保存
    savez () {
      if (this.model_class_on_inp_rcpt === "") {
        this.$message({ showClose: true, message: "住院收据分类不能为空！", type: "error" });
        return;
      }
      if (this.model_class_on_mr === "") {
        this.$message({ showClose: true, message: "病案首页费用分类不能为空！", type: "error" });
        return;
      }
      if (this.model_class_on_oup_rcpt === "") {
        this.$message({ showClose: true, message: "门诊收据分类不能为空！", type: "error" });
        return;
      }
      if (this.model_class_on_reckoning === "") {
        this.$message({ showClose: true, message: "核算项目分类不能为空！", type: "error" });
        return;
      }
      if (this.model_dose === "") {
        this.$message({ showClose: true, message: "最小单位剂量不能为空！", type: "error" });
        return;
      }
      if (this.model_dose_unit === "") {
        this.$message({ showClose: true, message: "剂量单位不能为空！", type: "error" });
        return;
      }
      // if (this.model_drug_code === "") {
      //     this.$message({showClose: true, message: "药品代码不能为空！", type: "error"});
      //     return;
      // }
      if (this.model_drug_flag === "") {
        this.$message({ showClose: true, message: "药品类别标志不能为空！", type: "error" });
        return;
      }
      if (this.model_drug_form === "") {
        this.$message({ showClose: true, message: "剂型不能为空！", type: "error" });
        return;
      }
      if (this.model_drug_name === "") {
        this.$message({ showClose: true, message: "药品名称不能为空！", type: "error" });
        return;
      }
      if (this.model_drug_spec === "") {
        this.$message({ showClose: true, message: "药品规格不能为空！", type: "error" });
        return;
      }
      if (this.model_gmp === "") {
        this.$message({ showClose: true, message: "gmp标志不能为空！", type: "error" });
        return;
      }
      if (this.model_hlimit_price === "") {
        this.$message({ showClose: true, message: "最高限价不能为空！", type: "error" });
        return;
      }
      if (this.model_iv_flag === "") {
        this.$message({ showClose: true, message: "大输液标记不能为空！", type: "error" });
        return;
      }
      if (this.model_limit_class === "") {
        this.$message({ showClose: true, message: "限制等级不能为空！", type: "error" });
        return;
      }
      if (this.model_min_spec === "") {
        this.$message({ showClose: true, message: "最小单位规格不能为空！", type: "error" });
        return;
      }
      if (this.model_min_unit === "") {
        this.$message({ showClose: true, message: "最小单位不能为空！", type: "error" });
        return;
      }
      if (this.model_otc === "") {
        this.$message({ showClose: true, message: "otc类型不能为空！", type: "error" });
        return;
      }
      if (this.model_package_count === "") {
        this.$message({ showClose: true, message: "包装数量不能为空！", type: "error" });
        return;
      }
      if (this.model_price_class === "") {
        this.$message({ showClose: true, message: "价格类别不能为空！", type: "error" });
        return;
      }
      if (this.model_retail_price === "") {
        this.$message({ showClose: true, message: "零售价不能为空！", type: "error" });
        return;
      }
      if (this.model_stop_flag === "") {
        this.$message({ showClose: true, message: "停用标志不能为空！", type: "error" });
        return;
      }
      if (this.model_storage_lower_limit === "") {
        this.$message({ showClose: true, message: "药库下限不能为空！", type: "error" });
        return;
      }
      if (this.model_storage_upper_limit === "") {
        this.$message({ showClose: true, message: "药库上限不能为空！", type: "error" });
        return;
      }
      if (this.model_store_lower_limit === "") {
        this.$message({ showClose: true, message: "药房下限不能为空！", type: "error" });
        return;
      }
      if (this.model_store_upper_limit === "") {
        this.$message({ showClose: true, message: "药房上限不能为空！", type: "error" });
        return;
      }
      if (this.model_subj_code === "") {
        this.$message({ showClose: true, message: "会计科目不能为空！", type: "error" });
        return;
      }
      if (this.model_toxi_property === "") {
        this.$message({ showClose: true, message: "毒理分类不能为空！", type: "error" });
        return;
      }
      if (this.model_trade_price === "") {
        this.$message({ showClose: true, message: "批发价不能为空！", type: "error" });
        return;
      }
      if (this.model_unit === "") {
        this.$message({ showClose: true, message: "单位不能为空！", type: "error" });
        return;
      }

      this.Newlyadded = false;
      var data = {
        model: "11.综合维护-药品字典维护",
        code: "11011",
        input: {
          class_on_inp_rcpt: this.model_class_on_inp_rcpt,
          class_on_mr: this.model_class_on_mr,
          class_on_oup_rcpt: this.model_class_on_oup_rcpt,
          class_on_reckoning: this.model_class_on_reckoning,
          create_time: this.model_create_time == "" ? "2019-08-08" : this.model_create_time,
          dose: this.model_dose,
          dose_unit: this.model_dose_unit,
          drug_code: this.model_drug_code,
          drug_flag: this.model_drug_flag,
          drug_form: this.model_drug_form,
          drug_name: this.model_drug_name,
          drug_spec: this.model_drug_spec,
          gmp: this.model_gmp,
          hlimit_price: this.model_hlimit_price,
          hospital_id: this.model_hospital_id == "" ? "1003" : this.model_hospital_id,
          iv_flag: this.model_iv_flag,
          limit_class: this.model_limit_class,
          min_spec: this.model_min_spec,
          min_unit: this.model_min_unit,
          otc: this.model_otc,
          package_count: this.model_package_count,
          pass_no: this.model_pass_no,
          price_class: this.model_price_class,
          pym: this.model_pym,
          retail_price: this.model_retail_price,
          stop_flag: this.model_stop_flag == true ? "1" : "0",
          storage_lower_limit: this.model_storage_lower_limit,
          storage_upper_limit: this.model_storage_upper_limit,
          store_lower_limit: this.model_store_lower_limit,
          store_upper_limit: this.model_store_upper_limit,
          subj_code: this.model_subj_code,
          toxi_property: this.model_toxi_property,
          trade_price: this.model_trade_price,
          unit: this.model_unit
        }
      };
      this.$post("CloudHIS/Business_Handle", data)
        .then(res => {
          if (res.code == 0) {
            this.model_XZBJ = "1"
            this.$message({ message: res.msg, type: "success" });
            this.queryz();
            this.addMasterUser();
            this.Newlyadded = false;
            document.getElementById("2").focus();
          } else {
            this.$message({ showClose: true, message: res.msg, type: "error" });
            this.Newlyadded = false;
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    //删除主表信息
    deletez () {

      var data = {
        model: "11.综合维护-药品字典维护",
        code: "11013",
        input: {
          drug_code: this.model_drug_code,
          drug_spec: this.model_drug_spec
        }
      };
      this.$post("CloudHIS/Business_Handle", data)
        .then(res => {
          if (res.code == 0) {
            this.$message({ message: res.msg, type: "success" });
            this.queryz();
            this.addMasterUser();
          } else {
            this.$message({ showClose: true, message: res.msg, type: "error" });
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    //主表查询

    queryz () {
      this.model_query = [];
      var data = {
        model: "11.综合维护-药品字典维护",
        code: "11012",
        input: {

          jm: this.model_jmC ? this.model_jmC : "",
          drug_flag: this.model_drug_flagC ? this.model_drug_flagC : -1,//药品类别标志
          drug_form: this.model_drug_formC ? this.model_drug_formC : -1, //剂型
          toxi_property: this.model_toxi_propertyC
            ? this.model_toxi_propertyC
            : -1, //毒理分类
          otc: this.model_otcC ? this.model_otcC : -1, //otc类型
          iv_flag: this.model_iv_flagC ? this.model_iv_flagC : -1, //大输液标记
          price_class: this.model_price_classC ? this.model_price_classC : -1, //价格类别
          stop_flag: this.model_stop_flagC ? this.model_stop_flagC : -1, //停用标志

          // Page: this.currentPage,
          // PageSize: this.pagesize
        }
      };
      console.log(data);
      this.$post("CloudHIS/Business_Handle", data)
        .then(res => {
          if (this.model_XZBJ == "1") {
            this.model_query.push(res.data[res.data.length - 1]); this.model_XZBJ = "";
            this.changeSelectStyle = "0";
          } else {
            this.model_query = res.data;
            this.addMasterUser();
          }

          console.log("查询结果");
          console.log(res);
        })
        .catch(err => {
          console.log(err);
        });
    },
    submit1 () {
      var ele = window.event.srcElement;
      var idcount = parseInt(ele.id) + 1;

      document.getElementById(idcount + "").focus();
    },
    queryG (KeyCode) {
      this.model_query = [];
      var data = {
        code: 'get_sys_dict2',
        input: {
          code: KeyCode
        }
      };
      this.$post("CloudHIS/getRedisDataByCode", data)
        .then(res => {
          console.log(res);
          for (var i = 0; i < res.data.length; i++) {
            if (res.data[i].keycode == "mr_class_code") {
              this.model_select_class_on_mr = res.data[i].dtl;
            }
            if (res.data[i].keycode == "oup_class_code") {
              this.model_select_class_on_oup_rcpt = res.data[i].dtl;
            }
            if (res.data[i].keycode == "drug_form_code") {
              this.model_select_drug_form = res.data[i].dtl;
            }
            if (res.data[i].keycode == "subj_class_code") {
              this.model_select_subj_code = res.data[i].dtl;
            }
            if (res.data[i].keycode == "unit_code") {
              this.model_select_unit = res.data[i].dtl;
              this.model_select_min_unit = res.data[i].dtl;
              this.model_select_dose_unit = res.data[i].dtl;
            }
            if (res.data[i].keycode == "inp_class_code") {
              this.model_select_class_on_inp_rcpt = res.data[i].dtl;
            }
            if (res.data[i].keycode == "price_categories") {
              this.model_select_price_class = res.data[i].dtl;
            }
            if (res.data[i].keycode == "toxicology") {
              this.model_select_toxi_property = res.data[i].dtl;
            }
            if (res.data[i].keycode == "tag") {
              this.model_select_iv_flag = res.data[i].dtl;
              this.model_select_stop_flag = res.data[i].dtl;
              this.model_select_gmp = res.data[i].dtl;
            }
            if (res.data[i].keycode == "drug_class_code") {
              this.model_select_drug_flag = res.data[i].dtl;
            }
            if (res.data[i].keycode == "otc_type") {
              this.model_select_otc = res.data[i].dtl;
            }
            if (res.data[i].keycode == "Limit_level") {
              this.model_select_limit_class = res.data[i].dtl;

            }
            if (res.data[i].keycode == "reckoning_class_code") {
              this.model_select_class_on_reckoning = res.data[i].dtl;
            }

          }
        })
        .catch(err => {
          console.log(err);
        });
    },

    addMasterUser () {
      this.Newlyadded = true;
      this.model_class_on_inp_rcpt = "";
      this.model_class_on_mr = "";
      this.model_class_on_oup_rcpt = "";
      this.model_class_on_reckoning = "";
      this.model_create_time = "";
      this.model_dose = "";
      this.model_dose_unit = "";
      this.model_drug_code = "";
      this.model_drug_flag = "";
      this.model_drug_form = "";
      this.model_drug_name = "";
      this.model_drug_spec = "";
      this.model_gmp = "";
      this.model_hlimit_price = "";
      this.model_hospital_id = "";
      this.model_iv_flag = "";
      this.model_limit_class = "";
      this.model_min_spec = "";
      this.model_min_unit = "";
      this.model_otc = "";
      this.model_package_count = "";
      this.model_pass_no = "";
      this.model_price_class = "";
      this.model_pym = "";
      this.model_retail_price = "";
      this.model_stop_flag = "";
      this.model_storage_lower_limit = "";
      this.model_storage_upper_limit = "";
      this.model_store_lower_limit = "";
      this.model_store_upper_limit = "";
      this.model_subj_code = "";
      this.model_toxi_property = "";
      this.model_trade_price = "";
      this.model_unit = "";
      document.getElementById("1").focus();
    },
    submit (item, index) {
      this.index = index;
      console.log(item);
      var arr = window.document.getElementsByTagName("input");
      for (var i = 0; i < arr.length; i++) {
        var t = arr[i];
        t.index = i;
        t.onkeydown = function (event) {
          if (event.keyCode == 13) {
            var next = this.index + 1;
            arr[next].focus();
          }
        };
      }
    },
    palction () {
      console.log(this.drug_dict.data);
    },
    current_change (currentPage) {
      this.currentPage = currentPage;
      this.queryz();
    }
  },
  mounted () {
    document.getElementById("2").focus();
  },
  created () {
    if (this.$route.query.Token) {
      localStorage.setItem('Token', this.$route.query.Token)
    }
    this.queryz();
    var a = [
      "mr_class_code",
      "oup_class_code",
      "drug_form_code",
      "subj_class_code",
      "unit_code",
      "inp_class_code",
      "price_categories",
      "toxicology",
      "tag",
      "drug_class_code",
      "otc_type",
      "Limit_level",
      "reckoning_class_code"
    ];
    this.queryG(a);
    // for (var i = 0; i < a.length; i++) {
    //     var str = a[i];
    //     this.queryG(str);
    // }
  }
};
</script>
<style lang="scss">
.PersonnelCategory {
  .pharmacopeia .m0 .form-group p {
    margin: 3px 10px 2px 5px;
  }

  .pharmacopeia .m0 fieldset label {
    height: 26px !important;
    line-height: 25px !important;
    padding-right: 3px;
    font-size: 13px;
  }

  .pharmacopeia .m0 fieldset .form-control {
    width: 110px;
    padding: 0 5px;
    height: 26px;
  }

  .pharmacopeia .m0 fieldset .btn {
    padding: 2px 12px;
    float: left;
  }

  .pharmacopeia .btnLine {
    height: 36px;
    margin-top: -8px;
  }

  .pharmacopeia .btnLine .btn {
    padding: 2px 12px;
  }

  .pharmacopeia .btnLine .mark1 {
    margin-top: 1px;
  }

  .pharmacopeia .threeSet {
    height: 225px;
  }

  .pharmacopeia .threeSet fieldset:first-child {
    margin: 0;
    width: 635px;
    float: left;
  }

  .pharmacopeia .threeSet fieldset:nth-child(2) {
    width: 381px;
    position: absolute;
    left: 560px;
    margin-top: 0;
    height: 151px;
    border-left: 1px solid #eee;
    border-right: 1px solid #eee;
  }

  .pharmacopeia .threeSet fieldset:nth-child(3) {
    position: absolute;
    left: 938px;
    margin-top: 0;
  }

  .pharmacopeia .threeSet fieldset:nth-child(4) {
    float: left;
    width: 380px;
  }

  .pharmacopeia .threeSet fieldset:nth-child(5) {
    width: 561px;
    position: relative;
    top: -76px;
    left: 380px;
    border-left: 1px solid #eee;
    border-right: 1px solid #eee;
  }

  .pharmacopeia .threeSet fieldset {
    margin: 0;
    clear: both;
    border-top: 1px solid #eee;
    border-left: none;
    border-right: none;
    padding-bottom: 0;
    border-bottom: none;
  }

  .pharmacopeia .threeSet fieldset legend {
    padding: 0 5px 3px 5px;
    font-weight: 700;
    color: #256192;
    margin-bottom: -3px;
    background: #fff;
  }

  .pharmacopeia .threeSet fieldset label {
    height: 26px;
    line-height: 25px;
    min-width: 65px;
    padding-right: 3px;
    font-size: 13px;
  }

  .pharmacopeia .threeSet fieldset .form-control {
    width: 110px;
    padding: 0 3px;
    height: 26px;
  }

  .pharmacopeia .threeSet fieldset div {
    clear: both;
  }

  .pharmacopeia .threeSet fieldset p {
    margin: 0 0 0 5px;
  }

  .pharmacopeia .table th,
  .pharmacopeia .table td {
    white-space: nowrap;
  }
}
</style>
